import sys
sys.path.append("..")
from tensor import Tensor
import numpy as np
from time import time


# a = np.array(
# 	[
# 	[[4,3,4],
# 	[2,3,4],
# 	[2,1,2]],

# 	[[4,3,4],
# 	[2,3,4],
# 	[2,1,2]]
# 	],
# 	dtype=np.float64
# 	)

a = np.array(
	[[
	[1.,1],
	[1,1]
	]]
	)

k = np.array(
	[[1.,2],
	[3,4]])

f = np.array([[[[1]]]])


A = Tensor(a.shape)
K = Tensor(k.shape)
feature = Tensor(f.shape)

# a = np.array(
# 	[[[
# 	[1.,2,3,4],
# 	[5,6,7,8],
# 	[9,1,2,3],
# 	[4,5,6,7]
# 	]]]
# 	)





A.inputValue(a)
K.inputValue(k)
feature.inputValue(f)
out = A.conv2d(kernel=K)
loss = out.MSELoss(feature)
A.forward()
print(out)
loss.backward()
print(A.grad)
print(K.grad)


# loss = out.MSELoss(feature)
# loss.backward()
# print(A.grad)
# print('=================')
# print(K.grad)

























